﻿/*----------------------------------------------------------------
           // Copyright (C) 2008 安华顺通(北京)科技有限公司
           // 版权所有。 
           //
           // 文件名：SysCompilerTable.cs
           // 文件功能描述：表编译功能。
           //
           // 
           // 创建标识：姓名20080916
           //
           // 修改标识
           // 修改描述：
           //
           // 修改标识：
           // 修改描述：
----------------------------------------------------------------*/

using System.Collections.Generic;

namespace RuleCode.Common
{
    /// <summary>
    /// 对象树中 表中的 字段的集合
    /// </summary>
    public struct AOTField
    {
        private string fieldName;
        public string FieldName
        {
            get
            {                
                return this.fieldName;
            }
            set 
            {
                this.fieldName = value;
            }
        }

        private System.Type fieldType;
        public System.Type FieldType
        {
            get { return this.fieldType;  }
            set { this.fieldType = value; }
        }

        private string id;
        public string ID
        {
            get { return this.id;  }
            set { this.id = value; }
        }        

    }

    /// <summary>
    /// 对像树 表中 字段组 类
    /// </summary>
    public struct AOTFieldGroup
    {
        private List<AOTField> group;
        public List<AOTField>  FieldGroup
        {
            get 
            {
                if (this.group == null)
                    this.group = new List<AOTField>();
                return this.group;
            }
            set 
            {
                this.group = value;
            }
        }

        private string name;
        public string Name
        {
            get { return this.name;  }
            set { this.name = value; }
        }

        private string label;
        public string Label
        {
            get { return this.label;  }
            set { this.label = value; }
        }

        private string id;
        public string ID
        {
            get { return this.id;  }
            set { this.id = value; }
        }


    }

    /// <summary>
    /// 对象树 表 的索引 
    /// </summary>
    public struct AOTTableIndex
    {
        private List<AOTField> group;
        public List<AOTField>  FieldGroup
        {
            get
            {
                if (this.group == null)
                    this.group = new List<AOTField>();
                return this.group;
            }
            set
            {
                this.group = value;
            }
        }

        private string name;
        public string Name
        {
            get { return this.name; }
            set { this.name = value; }
        }

        private string label;
        public string Label
        {
            get { return this.label; }
            set { this.label = value; }
        }

        private string id;
        public string ID
        {
            get { return this.id; }
            set { this.id = value; }
        }


      


        private bool enabled;
        public bool Enabled
        {
            get { return this.enabled;  }
            set { this.enabled = value; }
        }


        private bool allowDuplicates;
        public bool AllowDuplicates
        {
            get { return this.allowDuplicates;  }
            set { this.allowDuplicates = value; }
        }
    }


    /// <summary>
    /// 对象树中 使用的 表之间的关系类
    /// </summary>
    public struct AOTTableRelation
    {
        private string tableName;
        public string TableName
        {
            get { return this.tableName;  }
            set { this.tableName = value; }
        }
        
        private System.Type tableType;
        public System.Type TableType
        {
            get { return this.tableType;  }
            set { this.tableType = value; }
        }

        
        public Dictionary<AOTField, AOTField> keys;
        /// <summary>
        /// 对应的字段,从表字段：主表字段
        /// </summary>
        public Dictionary<AOTField, AOTField> Keys
        {
            get 
            {
                if (this.keys == null)
                    this.keys = new Dictionary<AOTField, AOTField>();
                return this.keys; 
            }
        }
        private bool validate;
        public bool Validate
        {
            get { return this.validate;  }
            set { this.validate = value; }
        }


        private string name;
        public string Name
        {
            get { return this.name; }
            set { this.name = value; }
        }

        private string label;
        public string Label
        {
            get { return this.label; }
            set { this.label = value; }
        }

        private string id;
        public string ID
        {
            get { return this.id; }
            set { this.id = value; }
        }


    }

    /// <summary>
    /// 对象数中所使用的 删除表的时候 关联表的相关操作
    /// </summary>
    public struct AOTDeleteAction
    {
        private string tableName;
        public string TableName
        {
            get { return this.tableName;  }
            set { this.tableName = value ; }
        }
        private System.Type tableType;
        public System.Type TableType
        {
            get { return this.tableType;  }
            set { this.tableType = value; }
        }

        /// <summary>
        /// action=Cascade ,None....三种或四种方法
        /// </summary>
        private string action;
        public string Action
        {
            get { return this.action;  }
            set { this.action = value; }
        }

        private string name;
        public string Name
        {
            get { return this.name; }
            set { this.name = value; }
        }

        private string label;
        public string Label
        {
            get { return this.label; }
            set { this.label = value; }
        }

        private string id;
        public string ID
        {
            get { return this.id; }
            set { this.id = value; }
        }


        private DeleteAction deleteAction;
        /// <summary>
        /// 获取或设置当前表的 联级删除时的操作 None,Cascade,Restricted ,RestrictedCascade
        /// </summary>
        public DeleteAction DeleteAction
        {
            get { return this.deleteAction;  }
            set { this.deleteAction = value; }
        }
    }
}
